/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
//
// Copyright (c) 2006 Georgia Tech Research Corporation
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation;
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// Author: George F. Riley<riley@ece.gatech.edu>
//

// ns3 - On/Off Data Source Application class
// George F. Riley, Georgia Tech, Spring 2007
// Adapted from ApplicationFlow in GTNetS.

#ifndef __flow_server_application_h__
#define __flow_server_application_h__

#include "ns3/application.h"
#include "ns3/tcp-socket-factory.h"

namespace ns3 {

class Address;
class Socket;

class FlowServerApplication : public Application 
{
public:
  static TypeId GetTypeId (void);

  FlowServerApplication ();
  virtual ~FlowServerApplication();

protected:
  virtual void DoDispose (void);
private:
  // inherited from Application base class.
  virtual void StartApplication (void);    // Called at time specified by Start
  virtual void StopApplication (void);     // Called at time specified by Stop

  void HandleAccept (Ptr<Socket>, const Address& from);
  void HandleFlowFinish (Ptr<FlowServer>);

  Address         m_local;        // Local address

  Ptr<Socket>                 m_socket;       // Listening socket
  std::list<Ptr<FlowServer> > m_flowList;   //the accepted sockets
};

} // namespace ns3

#endif

